package store

import (
	"errors"
	"github.com/dgrijalva/jwt-go"
	"github.com/gin-gonic/gin"
)

func GetClaims(ctx *gin.Context) (*jwt.StandardClaims, error) {
	if value, exists := ctx.Get("claims"); exists {
		if v, o := value.(*jwt.StandardClaims); o {
			return v, nil
		}
		return nil, errors.New("jwt.StandardClaims类型断言失败")
	}
	return nil, errors.New("store查找'claims'值失败")
}

func SetClaims(ctx *gin.Context, claims *jwt.StandardClaims) {
	ctx.Set("claims", claims)
}
